home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Utilities / Calc / Makefile < prev    next >
Encoding:
Makefile  |  1993-10-12  |  13.0 KB  |  404 lines  |  [TEXT/????]

  1. #
  2. # Copyright (c) 1992 David I. Bell and Landon Curt Noll
  3. # Permission is granted to use, distribute, or modify this source,
  4. # provided that this copyright notice remains intact.
  5. #
  6. # Arbitrary precision calculator.
  7. #
  8. # calculator by David I. Bell
  9. # makefile by Landon Curt Noll
  10.  
  11. ##############################################################################
  12. #-=-=-=-=-=-=-=-=- You may want to change some values below -=-=-=-=-=-=-=-=-#
  13. ##############################################################################
  14.  
  15. VPATH = ../src
  16.  
  17. # Determine the type of varargs that you want to use
  18. #
  19. #    VARARG value      meaning
  20. #    ------------      -------
  21. #    (nothing)      let the makefile guess at what you need
  22. #    STDARG              you have ANSI C and /usr/include/stdarg.h
  23. #    VARARGS              you have /usr/include/varargs.h
  24. #    SIMULATE_STDARG   use simulated ./stdarg.h
  25. #
  26. # Try defining VARARG to be nothing.  The makefile will look for the
  27. # needed .h files, trying for stdarg.h first.
  28. #
  29. #VARARG=
  30. VARARG= STDARG
  31. #VARARG= VARARGS
  32. #VARARG= SIMULATE_STDARG
  33.  
  34. # If your system does not have a vsprintf() function, you could be in trouble.
  35. #
  36. #    vsprintf(stream, format, ap)
  37. #
  38. # This function works like sprintf except that the 3rd arg is a va_list
  39. # strarg (or varargs) list.
  40. #
  41. # If you have vsprintf, then define VSPRINTF to be an empty string.
  42. # Some old BSD systems do not have vsprintf().  If you do not have vsprintf()
  43. # then define VSPRINTF to be -DVSPRINTF and hope for the best.
  44. #
  45. VSPRINTF=
  46. #VSPRINTF= -DVSPRINTF
  47.  
  48. # Determine the byte order of your machine
  49. #
  50. #    Big Endian:    -DBIG_ENDIAN        Amdahl, 68000, Pyramid, Mips, ...
  51. #    Little Endian:    -DLITTLE_ENDIAN        Vax, 32000, 386, 486, ...
  52. #
  53. ENDIAN= -DBIG_ENDIAN
  54. #ENDIAN= -DLITTLE_ENDIAN
  55.  
  56. # Determine whether to use the standard UNIX malloc or the alternative one
  57. # included with the calculator.  On some machines, the alternative malloc
  58. # may be faster.  It also can help to debug malloc problems.  Define
  59. # -DUNIX_MALLOC to use the standard UNIX malloc routines.
  60. #
  61. # If in doubt, use the MALLOC= -DUNIX_MALLOC line.
  62. #
  63. MALLOC= -DUNIX_MALLOC
  64. #MALLOC=
  65.  
  66. # where to install binary files
  67. #
  68. BINDIR= /contrib/system/bin
  69.  
  70. # where to install the lib/*.calc files
  71. #
  72. LIBDIR= /contrib/share/lib/calc
  73.  
  74. # where to install help files
  75. #
  76. # The ${LIBDIR}/help is where the help files will be installed.
  77. #
  78. HELPDIR= ${LIBDIR}/help
  79.  
  80. # where man pages are installed
  81. #
  82. MANDIR=/contrib/share/man/man1
  83. #MANDIR=/usr/man/man1
  84. #MANDIR=/usr/share/man/man1
  85. #MANDIR=/usr/man/u_man/man1
  86.  
  87. # If the $CALCPATH environment variable is not defined, then the following
  88. # path will be search for calc lib routines.
  89. #
  90. CALCPATH= .:./lib:~/lib:${LIBDIR}
  91.  
  92. # If the $CALCRC environment variable is not defined, then the following
  93. # path will be search for calc lib routines.
  94. #
  95. CALCRC= ${LIBDIR}/startup:~/.calcrc
  96.  
  97. # If $PAGER is not set, use this program to display a help file
  98. #
  99. #CALCPAGER= less
  100. CALCPAGER= more
  101. #CALCPAGER= pg
  102. #CALCPAGER= cat
  103.  
  104. # Compile debug options
  105. #
  106. # Select -O, or empty string, if you don't want to debug
  107. DEBUG= -O
  108. #DEBUG= -g
  109. #DEBUG= -gx
  110. #DEBUG= -WM,-g
  111. #DEBUG=
  112.  
  113. # On systems that have dynamic shared libs, you want want to disable them
  114. # for faster calc startup.
  115. #
  116. NO_SHARED=
  117. #NO_SHARED= -dn
  118.  
  119. # Some systems (System V based mostly) allow 'mkdir -p' to make a directory
  120. # and any needed parent directories.  If you system has 'mkdir -p', then
  121. # leave the definition below, otherwise define MKDIR to be just 'mkdir'
  122. # or simply ensure that ${LIBDIR}, ${BINDIR} and ${HELPDIR} exist before
  123. # you do an install.
  124. #
  125. MKDIR=mkdir -p
  126. #MKDIR=mkdir
  127.  
  128. # If you are running an an classic BSD system, then you may not have
  129. # the following functions:
  130. #
  131. #    memcpy()    strchr()    memset()
  132. #
  133. # If you do not have these functions, define OLD_BSD to be -DOLD_BSD,
  134. # otherwise define OLD_BSD to be an empty string.
  135. #
  136. # BSD-like systems such an SunOS 4.x have these functions and thus don't 
  137. # need OLD_BSD.  If you don't know, try using the empty string and if
  138. # you get complaints, try -DOLD_BSD.
  139. #
  140. #OLD_BSD= -DOLD_BSD
  141. OLD_BSD=
  142.  
  143. ##############################################################################
  144. #-=-=-=-=-=-=-=-=- Be careful if you change something below -=-=-=-=-=-=-=-=-#
  145. ##############################################################################
  146.  
  147. # standard utilities used during make
  148. #
  149. SHELL= /bin/sh
  150. MAKE= make
  151. LINT= lint
  152. CC= cc
  153. CTAGS= ctags
  154.  
  155. # -b: ignore break; that are not reachable
  156. # -s: print lint problems one per line
  157. # -F: produce full path names for files
  158. #
  159. LINTFLAGS= -b -s -F
  160. #LINTFLAGS=
  161.  
  162. # the calc source files
  163. #
  164. CALCSRC= addop.c alloc.c calc.c codegen.c comfunc.c commath.c config.c \
  165.     const.c file.c func.c input.c io.c label.c listfunc.c matfunc.c obj.c \
  166.     opcodes.c qfunc.c qmath.c qmod.c qtrans.c string.c symbol.c token.c \
  167.     value.c version.c zfunc.c zmath.c zmod.c zmul.c
  168.  
  169. # we build these .o files for calc
  170. #
  171. CALCOBJS= addop.o alloc.o calc.o codegen.o comfunc.o commath.o config.o \
  172.     const.o file.o func.o input.o io.o label.o listfunc.o matfunc.o obj.o \
  173.     opcodes.o qfunc.o qmath.o qmod.o qtrans.o string.o symbol.o token.o \
  174.     value.o version.o zfunc.o zmath.o zmod.o zmul.o
  175.  
  176. # we build these .h files during the make
  177. #
  178. BUILD_H_SRC= config.h have_malloc.h have_stdlib.h have_string.h args.h
  179.  
  180. # The code program is not part of the calc distribution, don't worry
  181. # if you do not have it.
  182. #
  183. CODEOBJS= code.o io_code.o qfunc.o qmath_code.o zfunc.o zmath.o zmul.o zmod.o
  184.  
  185. # we build these .c files during the make
  186. #
  187. BUILD_CODE_SRC= io_code.c qmath_code.c
  188.  
  189. INCLUDE= -I.
  190.  
  191. CFLAGS= ${DEBUG} ${INCLUDE} ${MALLOC} ${ENDIAN} ${OLD_BSD} ${VSPRINTF}
  192.  
  193. all: calc
  194.  
  195. calc: ${CALCOBJS}
  196.     ${CC} ${CFLAGS} ${CALCOBJS} -o calc ${NO_SHARED}
  197.  
  198. config.h: Makefile
  199.     rm -f config.h
  200.     @echo '    forming config.h'
  201.     @echo '/*' > config.h
  202.     @echo ' * DO NOT EDIT -- generated by the Makefile' >> config.h
  203.     @echo ' */' >> config.h
  204.     @echo '' >> config.h
  205.     @echo '/* the default :-separated search path */' >> config.h
  206.     @echo '#ifndef DEFAULTCALCPATH' >> config.h
  207.     @echo '#define DEFAULTCALCPATH "${CALCPATH}"' >> config.h
  208.     @echo '#endif /* DEFAULTCALCPATH */' >> config.h
  209.     @echo '' >> config.h
  210.     @echo '/* the default :-separated startup file list */' >> config.h
  211.     @echo '#ifndef DEFAULTCALCRC' >> config.h
  212.     @echo '#define DEFAULTCALCRC "${CALCRC}"' >> config.h
  213.     @echo '#endif /* DEFAULTCALCRC */' >> config.h
  214.     @echo '' >> config.h
  215.     @echo '/* the location of the help directory */' >> config.h
  216.     @echo '#ifndef HELPDIR' >> config.h
  217.     @echo '#define HELPDIR "${HELPDIR}"' >> config.h
  218.     @echo '#endif /* HELPDIR */' >> config.h
  219.     @echo '' >> config.h
  220.     @echo '/* the default pager to use */' >> config.h
  221.     @echo '#ifndef DEFAULTCALCPAGER' >> config.h
  222.     @echo '#define DEFAULTCALCPAGER "${CALCPAGER}"' >> config.h
  223.     @echo '#endif /* DEFAULTCALCPAGER */' >> config.h
  224.     @echo '    config.h formed'
  225.  
  226. have_malloc.h: Makefile
  227.     rm -f have_malloc.h
  228.     @echo '    forming have_malloc.h'
  229.     @echo '/*' > have_malloc.h
  230.     @echo ' * DO NOT EDIT -- generated by the Makefile' >> have_malloc.h
  231.     @echo ' */' >> have_malloc.h
  232.     @echo '' >> have_malloc.h
  233.     @echo '/* do we have /usr/include/malloc.h? */' > have_malloc.h
  234.     -@if [ -r /usr/include/malloc.h ]; then \
  235.         echo '#define HAVE_MALLOC_H  /* yes */' >> have_malloc.h; \
  236.     else \
  237.         echo '#undef HAVE_MALLOC_H   /* no */' >> have_malloc.h; \
  238.     fi
  239.     @echo '    have_malloc.h formed'
  240.  
  241. have_stdlib.h: Makefile
  242.     rm -f have_stdlib.h
  243.     @echo '    forming have_stdlib.h'
  244.     @echo '/*' > have_stdlib.h
  245.     @echo ' * DO NOT EDIT -- generated by the Makefile' >> have_stdlib.h
  246.     @echo ' */' >> have_stdlib.h
  247.     @echo '' >> have_stdlib.h
  248.     @echo '/* do we have /usr/include/stdlib.h? */' > have_stdlib.h
  249.     -@if [ -r /usr/include/stdlib.h ]; then \
  250.         echo '#define HAVE_STDLIB_H  /* yes */' >> have_stdlib.h; \
  251.     else \
  252.         echo '#undef HAVE_STDLIB_H   /* no */' >> have_stdlib.h; \
  253.     fi
  254.     @echo '    have_stdlib.h formed'
  255.  
  256. have_string.h: Makefile
  257.     rm -f have_string.h
  258.     @echo '    forming have_string.h'
  259.     @echo '/*' > have_string.h
  260.     @echo ' * DO NOT EDIT -- generated by the Makefile' >> have_string.h
  261.     @echo ' */' >> have_string.h
  262.     @echo '' >> have_string.h
  263.     @echo '/* do we have /usr/include/string.h? */' > have_string.h
  264.     -@if [ -r /usr/include/string.h ]; then \
  265.         echo '#define HAVE_STRING_H  /* yes */' >> have_string.h; \
  266.     else \
  267.         echo '#undef HAVE_STRING_H   /* no */' >> have_string.h; \
  268.     fi
  269.     @echo '    have_string.h formed'
  270.  
  271. args.h: Makefile
  272.     rm -f args.h
  273.     @echo '    forming args.h'
  274.     @echo '/*' > args.h
  275.     @echo ' * DO NOT EDIT -- generated by the Makefile' >> args.h
  276.     @echo ' */' >> args.h
  277.     @echo '' >> args.h
  278.     @echo '/* what sort of variable args do we have? */' > args.h
  279.     -@if [ ! -z "${VARARG}" ]; then \
  280.         echo '#define ${VARARG}' >> args.h; \
  281.     elif [ -r /usr/include/stdarg.h ]; then \
  282.         echo '#define STDARG' >> args.h; \
  283.     elif [ -r /usr/include/varargs.h ]; then \
  284.         echo '#define VARARGS' >> args.h; \
  285.     else \
  286.         echo '#define SIMULATE_STDARG' >> args.h; \
  287.     fi
  288.     @echo '    args.h formed'
  289.  
  290. help/full: help/Makefile
  291.     cd help; ${MAKE} -f Makefile HELPDIR=${HELPDIR} full
  292.  
  293. lint: ${BUILD_H_SRC} ${CALCSRC} lint.sed
  294.     ${LINT} ${LINTFLAGS} ${CFLAGS} ${CALCSRC} | sed -f lint.sed
  295.  
  296. tags: ${CALCSRC}
  297.     ${CTAGS} ${CALCSRC}
  298.  
  299. clean:
  300.     rm -f ${CALCOBJS} ${CODEOBJS}
  301.     rm -f tags calc code ${BUILD_CODE_SRC}
  302.     rm -f ${BUILD_H_SRC}
  303.     cd help; ${MAKE} -f Makefile clobber
  304.  
  305. install: all calc.1
  306.     -@if [ ! -d ${LIBDIR} ]; then \
  307.         echo "    ${MKDIR} ${LIBDIR}"; \
  308.         ${MKDIR} ${LIBDIR}; \
  309.     fi
  310.     -@if [ ! -d ${HELPDIR} ]; then \
  311.         echo "    ${MKDIR} ${HELPDIR}"; \
  312.         ${MKDIR} ${HELPDIR}; \
  313.     fi
  314.     -@if [ ! -d ${BINDIR} ]; then \
  315.         echo "    ${MKDIR} ${BINDIR}"; \
  316.         ${MKDIR} ${BINDIR}; \
  317.     fi
  318.     chmod 0755 calc
  319.     cp calc ${BINDIR}
  320.     cd help; ${MAKE} -f Makefile HELPDIR=${HELPDIR} install
  321.     cd lib; ${MAKE} -f Makefile LIBDIR=${LIBDIR} install
  322.     -chmod 0444 calc.1
  323.     -cp calc.1 ${MANDIR}
  324. # The code program is not part of the calc distribution, don't worry
  325. # if you do not have it.
  326.     -@if [ -f code ]; then \
  327.         echo "    chmod +x code"; \
  328.         chmod +x code; \
  329.         echo "    cp code ${BINDIR}"; \
  330.         cp code ${BINDIR}; \
  331.     fi
  332.  
  333. # The code program is not part of the calc distribution, don't worry
  334. # if you do not have it.
  335. #
  336. code: ${CODEOBJS}
  337.     ${CC} ${CFLAGS} ${CODEOBJS} -o code ${NO_SHARED}
  338. io_code.o: calc.h math.h alloc.h have_string.h have_stdlib.h have_malloc.h \
  339.     func.h opcodes.h config.h token.h symbol.h io_code.c
  340.     ${CC} ${CFLAGS} -DCODE io_code.c -c
  341. qmath_code.o: calc.h math.h alloc.h have_string.h have_stdlib.h have_malloc.h \
  342.     func.h opcodes.h config.h token.h symbol.h qmath_code.c
  343.     ${CC} ${CFLAGS} -DCODE qmath_code.c -c
  344. io_code.c: io.c
  345.     rm -f io_code.c
  346.     cp io.c io_code.c
  347. qmath_code.c: qmath.c
  348.     rm -f qmath_code.c
  349.     cp qmath.c qmath_code.c
  350. code.o: stdarg.h args.h math.h have_malloc.h Makefile
  351.     ${CC} ${CFLAGS} -DCODE code.c -c
  352.  
  353. # make depend stuff
  354. #
  355. addop.o: calc.h math.h alloc.h have_string.h have_stdlib.h \
  356.     have_malloc.h opcodes.h string.h func.h token.h label.h symbol.h
  357. alloc.o: alloc.h have_string.h have_stdlib.h
  358. calc.o: calc.h math.h alloc.h have_string.h have_stdlib.h \
  359.     have_malloc.h func.h opcodes.h config.h token.h symbol.h
  360. codegen.o: calc.h math.h alloc.h have_string.h have_stdlib.h \
  361.     have_malloc.h token.h symbol.h label.h opcodes.h string.h \
  362.     func.h config.h
  363. comfunc.o: calc.h math.h alloc.h have_string.h have_stdlib.h \
  364.     have_malloc.h
  365. commath.o: math.h alloc.h have_string.h have_stdlib.h have_malloc.h
  366. config.o: calc.h math.h alloc.h have_string.h have_stdlib.h \
  367.     have_malloc.h
  368. const.o: calc.h math.h alloc.h have_string.h have_stdlib.h have_malloc.h
  369. file.o: stdarg.h args.h calc.h math.h alloc.h have_string.h have_stdlib.h \
  370.     have_malloc.h have_string.h
  371. func.o: calc.h math.h alloc.h have_string.h have_stdlib.h \
  372.     have_malloc.h opcodes.h token.h func.h string.h
  373. input.o: calc.h math.h alloc.h have_string.h have_stdlib.h \
  374.     have_malloc.h config.h func.h
  375. io.o: stdarg.h args.h math.h alloc.h have_string.h have_stdlib.h \
  376.     have_malloc.h Makefile
  377. label.o: calc.h math.h alloc.h have_string.h have_stdlib.h \
  378.     have_malloc.h token.h label.h string.h opcodes.h func.h
  379. listfunc.o: calc.h math.h alloc.h have_string.h have_stdlib.h \
  380.     have_malloc.h
  381. matfunc.o: calc.h math.h alloc.h have_string.h have_stdlib.h \
  382.     have_malloc.h
  383. obj.o: calc.h math.h alloc.h have_string.h have_stdlib.h have_malloc.h \
  384.     opcodes.h func.h symbol.h string.h
  385. opcodes.o: stdarg.h args.h calc.h math.h alloc.h have_string.h have_stdlib.h \
  386.     have_malloc.h have_string.h opcodes.h func.h symbol.h Makefile
  387. qfunc.o: math.h alloc.h have_string.h have_stdlib.h have_malloc.h
  388. qmath.o: math.h alloc.h have_string.h have_stdlib.h have_malloc.h
  389. qmod.o: math.h alloc.h have_string.h have_stdlib.h have_malloc.h
  390. qtrans.o: math.h alloc.h have_string.h have_stdlib.h have_malloc.h
  391. string.o: calc.h math.h alloc.h have_string.h have_stdlib.h \
  392.     have_malloc.h string.h
  393. symbol.o: calc.h math.h alloc.h have_string.h have_stdlib.h \
  394.     have_malloc.h token.h symbol.h string.h opcodes.h func.h
  395. token.o: stdarg.h args.h calc.h math.h alloc.h have_string.h have_stdlib.h \
  396.     have_malloc.h have_string.h token.h string.h Makefile
  397. value.o: calc.h math.h alloc.h have_string.h have_stdlib.h \
  398.     have_malloc.h opcodes.h func.h symbol.h
  399. zfunc.o: math.h alloc.h have_string.h have_stdlib.h have_malloc.h
  400. zmath.o: math.h alloc.h have_string.h have_stdlib.h have_malloc.h
  401. zmod.o: math.h alloc.h have_string.h have_stdlib.h have_malloc.h
  402. zmul.o: math.h alloc.h have_string.h have_stdlib.h have_malloc.h
  403.  
  404.